from django.db import models


# 测试
class TestUser(models.Model):
    name = models.CharField(max_length=32)
    pwd = models.CharField(max_length=32)



# 用户表
class User(models.Model):
    id = models.CharField(max_length=50, primary_key=True)
    wx_id = models.CharField(max_length=50, unique=True, default='')
    name = models.CharField(max_length=32, default='')
    head = models.CharField(max_length=1024, default='')
    phone = models.CharField(max_length=15, default='')
    like = models.IntegerField(default=0)


# token
class UserToken(models.Model):
    user_id = models.CharField(max_length=50, primary_key=True)
    token = models.CharField(max_length=50,unique=True, default='')
    invalid_time = models.BigIntegerField(default=0)


# 游戏表
class Game(models.Model):
    id = models.CharField(max_length=50, primary_key=True)
    name = models.CharField(max_length=20, unique=True)
    icon = models.CharField(max_length=1024, default='')
    image = models.CharField(max_length=1024, default='')
    status = models.IntegerField(default=0)


# 好友关系表
class Friends(models.Model):
    id = models.CharField(max_length=50, primary_key=True)
    user_id = models.CharField(max_length=50)
    friend_id = models.CharField(max_length=50)


# 用户余额表
class Balance(models.Model):
    id = models.CharField(max_length=50, primary_key=True)
    user_id = models.CharField(max_length=50)
    balance = models.IntegerField()
    timestamp = models.BigIntegerField()


# 红包表
class RedPacket(models.Model):
    id = models.CharField(max_length=50, primary_key=True)
    user_id = models.CharField(max_length=50)
    money = models.IntegerField()
    num = models.IntegerField()
    game_id = models.CharField(max_length=50)
    packet_id = models.CharField(max_length=50)
    timestamp = models.BigIntegerField()
    invalid_time = models.BigIntegerField()
    grade = models.IntegerField()
    status = models.IntegerField(default=0)


# 红包的子红包表
class RedPacketSub(models.Model):
    id = models.CharField(max_length=50, primary_key=True)
    packet_id = models.CharField(max_length=50)
    money = models.IntegerField()
    user = models.ForeignKey(User, on_delete=models.DO_NOTHING, default=None, null=True)
    timestamp = models.BigIntegerField(default=0)


# 记录红包的code
class PacketCode(models.Model):
    id = models.BigAutoField(primary_key=True)
    code = models.CharField(max_length=32)


# 游戏难度详情
class GameDifficultyDetail(models.Model):
    id = models.BigAutoField(primary_key=True)
    game_id = models.CharField(max_length=50)
    detail = models.CharField(max_length=1024)
    grade = models.IntegerField()



